﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace QYmall.Core.Model.Models
{
    /// <summary>
    /// 订单收款单
    /// </summary>
    public class OrderCollection
    {
        /// <summary>
        /// 自增ID
        /// </summary>
        [Display(Name = "自增ID")]
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long Id { get; set; }

        /// <summary>
        /// 所属用户
        /// </summary>
        [Display(Name = "所属用户")]
        public int UserId { get; set; }

        /// <summary>
        /// 交易单号
        /// </summary>
        [Display(Name = "交易单号")]
        [Required]
        [StringLength(128)]
        public string? TradeNo { get; set; }

        /// <summary>
        /// 交易类型
        /// 0商品1充值
        /// </summary>
        [Display(Name = "交易类型")]
        public byte TradeType { get; set; } = 0;

        /// <summary>
        /// 收款类型
        /// 0全款
        /// 1预付款
        /// 2尾款
        /// </summary>
        [Display(Name = "收款类型")]
        public byte CollectionType { get; set; } = 0;

        /// <summary>
        /// 支付方式ID
        /// </summary>
        [Display(Name = "支付方式")]
        [ForeignKey("Payment")]
        public int PaymentId { get; set; }

        /// <summary>
        /// 支付方式名称
        /// </summary>
        [Display(Name = "支付名称")]
        public string? PaymentTitle { get; set; }

        /// <summary>
        /// 支付类型
        /// 0在线支付
        /// 1货到付款
        /// </summary>
        [Display(Name = "收款类型")]
        public byte PaymentCash { get; set; } = 0;

        /// <summary>
        /// 运费金额
        /// </summary>
        [Display(Name = "运费金额")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal FreightAmount { get; set; } = 0;

        /// <summary>
        /// 优惠金额
        /// </summary>
        [Display(Name = "优惠金额")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal DiscountAmount { get; set; } = 0;

        /// <summary>
        /// 付款金额
        /// </summary>
        [Display(Name = "付款金额")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal PaymentAmount { get; set; } = 0;

        /// <summary>
        /// 备注说明
        /// </summary>
        [Display(Name = "备注说明")]
        [StringLength(512)]
        public string? Remark { get; set; }

        /// <summary>
        /// 收款状态
        /// 1未支付
        /// 2已支付
        /// 3已取消
        /// </summary>
        [Display(Name = "收款状态")]
        public byte Status { get; set; } = 1;

        /// <summary>
        /// 开始时间
        /// </summary>
        [Display(Name = "开始时间")]
        public DateTime StartTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 失效时间
        /// </summary>
        [Display(Name = "失效时间")]
        public DateTime EndTime { get; set; } = DateTime.Now.AddMinutes(10);

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "操作时间")]
        public DateTime AddTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 完成时间
        /// </summary>
        [Display(Name = "完成时间")]
        public DateTime? CompleteTime { get; set; }

        /// <summary>
        /// 会员充值订单列表
        /// </summary>
        public ICollection<MemberRecharge> Recharges { get; set; } = new List<MemberRecharge>();

        // <summary>
        /// 订单收款关联列表
        /// </summary>
        public ICollection<OrderCollectionRelation> CollectionRelations { get; set; } = new List<OrderCollectionRelation>();

        /// <summary>
        /// 支付方式
        /// </summary>
        public Payment? Payment { get; set; }
    }
}
